package com.nulldev.util.uri.iwebkit2.document;

import java.util.HashMap;

public class Element {

	private ElementClass elementClass;
	private String _rawTagName;
	private String innerHTML;
	
	private HashMap<String, String> attributes;

	public void init() {
		this.attributes = new HashMap<String, String>();
		this._rawTagName = "";
	}
	
	public void setElementClass(final ElementClass cls) {
		this.elementClass = cls;
	}
	
	public void setTagName(final String tag) {
		this._rawTagName = tag;
	}

	public void registerAttribute(final String key, final String value) {
		this.attributes.put(key, value);
	}

	public String getAttribute(final String string) {
		return this.attributes.get(string);
	}
	
	public String getAttribute(final String string, final String fallback) {
		final String o = this.attributes.get(string);
		if (o != null) {
			return o;
		}
		return fallback;
	}
	
	public boolean isAttribute(final String attr) {
		return this.attributes.get(attr) != null;
	}

	public ElementClass getElementClass() {
		return this.elementClass;
	}
	
	public String getInnerHTML() {
		return this.innerHTML;
	}
	
	public void setInnerHTML(final String html) {
		this.innerHTML = html;
	}
	
	@Override
	public String toString() {
		return "iWebKit2.Element[elementClass=" + this.elementClass + ",tagName=" + this._rawTagName + "]";
	}
	
}
